The global
keyword allows one to access the global variable of the same name.
Meanwhile, the nonlocal
keyword allows one to access the variable of the same name of the outer scope. This tends to be used when you have a nested function, where nonlocal
is called by the nested function to get a handle on the variable in the main function.